package com.controller;

import com.pojo.Result;
import com.pojo.Users;
import com.service.UsersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/users")
public class UsersController {
    @Autowired
    private UsersService usersService;
    @GetMapping("/{userId}")
    public Result selectById(@PathVariable Integer userId) {
        log.info("根据ID查询用户");
        Users user = usersService.selectById(userId);

        return Result.success(user);
    }
    @PutMapping("/update")
    public Result updateById(@RequestBody Users user) {
        log.info("更新用户信息");
        Users u = usersService.updateById(user);

        return Result.success(u);
    }
}
